//
//  RootTabViewController.m
//  meishangBusiness
//
//  Created by Rui on 15/3/2.
//  Copyright (c) 2015年 xingheng. All rights reserved.
//

#import "RootTabViewController.h"
#import "ShopListViewController.h"
#import "warningViewController.h"
#import "mineViewController.h"


//#import "homeViewController.h"
//#import "shipgdsViewController.h"
//#import "shiplistViewController.h"
//#import "warningViewController.h"
//
//#import "Helpers.h"
//#import "TTNavigationController.h"

//#import "indexViewController.h"
//#import "ShipperSourceViewController.h"
//#import "ShipperOrderViewController.h"
//#import "AlarmViewController.h"

@interface RootTabViewController ()

@end

@implementation RootTabViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupViewControllers];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}

- (void)setupViewControllers
{
    
    // 货单
    UIViewController *shipOrder = [[ShopListViewController alloc] init];
    UIViewController *indexNav = [[TTNavigationController alloc]initWithRootViewController:shipOrder];
    
    // 告警
    UIViewController *warning = [[warningViewController alloc] init];
    UIViewController *warningNav = [[TTNavigationController alloc]initWithRootViewController:warning];
    
    // 我的
    UIViewController *mine = [[mineViewController alloc] init];
    UIViewController *mineNav = [[TTNavigationController alloc]initWithRootViewController:mine];
    
    
    [self setViewControllers:@[indexNav,warningNav,mineNav]];
    [self customizeTabBarForController];
}

- (void)customizeTabBarForController {

    //背景选中图
    UIImage *finishedImage = [UIImage imageNamed:@"tabar_bg"];
    //背景正常图
    UIImage *unfinishedImage = [UIImage imageNamed:@"tabar_bg"];
    //图片名称数组
    NSArray *tabBarItemImages = @[@"hd", @"gj", @"gr"];
    
    NSInteger index = 0;
    for (RDVTabBarItem *item in [[self tabBar] items]) {
        
        //设置tabBar垂直紧贴底部
        item.titlePositionAdjustment = UIOffsetMake(0, 3);
        //设置tabbar背景图
        [item setBackgroundSelectedImage:finishedImage withUnselectedImage:unfinishedImage];
        //选中图片
        UIImage *selectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@_pre",[tabBarItemImages objectAtIndex:index]]];
        //正常图片
        UIImage *unselectedimage = [UIImage imageNamed:[NSString stringWithFormat:@"%@",[tabBarItemImages objectAtIndex:index]]];
        [item setFinishedSelectedImage:selectedimage withFinishedUnselectedImage:unselectedimage];
        //选中状态文字颜色
        [item setSelectedTitleAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor HexStrWithColor:@"d23700"],@"NSColor",[UIFont systemFontOfSize:12],@"NSFont", nil]];
        //正常状态文字颜色
        [item setUnselectedTitleAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor HexStrWithColor:@"6e6e6e"],@"NSColor",[UIFont systemFontOfSize:12],@"NSFont", nil]];
        
        if (index == 0) {
            [item setTitle:@"货单"];
        }else if (index == 1){
            [item setTitle:@"告警"];
        }else if (index == 2){
            [item setTitle:@"我的"];
        }
        index++;
    }
}

@end
